<?php

class Admin_Quotation_Model extends Model
{
	public function __construct()
	{
		parent::Model();
		
		// open the database
		$this->load->database();
	}
	
	function read_address($address_id)
	{
		$row="";
		
		$query=$this->db->query('SELECT name, company_name, street, postal_code, city_id, province_id, country, phone, fax, email
							FROM address
							WHERE address_id = \''.$address_id.'\'');
							
		foreach($query->result() as $row)
		{
			//$province_state_list[$i] = $row->state_province_name;
		}

		return $row;
	}
	
	function get_city($city_id)
	{
		$row="";
		
		$query=$this->db->query('SELECT city_name, state_province_id
							FROM city
							WHERE city_id = \''.$city_id.'\'');

		foreach($query->result() as $row)
		{
//			echo $row->city_name;
		}

		return $row;
	}

	function get_province($province_id)
	{
		$row="";
		
		$query=$this->db->query('SELECT state_province_name, country_name
							FROM state_province
							WHERE state_province_id = \''.$province_id.'\'');
							
		foreach($query->result() as $row)
		{
			//$province_state_list[$i] = $row->state_province_name;
		}

		return $row;
	}
	
	function read_quotation($quotation_id)
	{
		$row="";
		
		$query=$this->db->query('SELECT requester_name, email, phone, origin_address_id, destination_address_id, pickup_date, goods_description, other_comment, handling_instruction, shipping_desctination_comment, designation_id, pickup_time, dock_closing_time, total_weight, is_hazardous, pieces
							FROM quotation
							WHERE quote_id = \''.$quotation_id.'\'');
							
		foreach($query->result() as $row)
		{
			//$province_state_list[$i] = $row->state_province_name;
		}

		return $row;
	}
	
	function get_designation_id($id)
	{
		
		$query=$this->db->query('SELECT designation_title
							FROM requester_designation
							WHERE designation_id = \''.$id.'\'');
							
		foreach($query->result() as $row)
		{
			return $row->designation_title;
		}
	}
}

?>